<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="../js/jquery.js"></script>
</head>
<body>
    
    <script>
        
        /* 模板字符串 */
    let name ="aa"
    const url = `https://api.github.com/search/users?q=${name}`
    $.ajax({
        url:url,
        success:function(data){
           console.log(data)
           let items = data.items

           let nwe =  items.map((params,index) => { 
               return `<div>${index}-- &gt; ${params.login} </div>`
            })
            // <img src="${params.avatar_url}" width='50px' alt="">
            document.write(nwe)
        },
        error:function(msg){
            alert('错误信息')
        }
    })
    let name = "aa"
        // const url = `http://127.0.0.1/react`
        const url = `https://api.github.com/search/users?q=${name}`
        fetch(url).then(function (request) {
            // 求解转化的方法,多一步转化数据的方法
            return request.json()
        }).then(function (data) {
            console.log(data)
            let items = data.items
            let nwe = items.map((params, index) => {
                return `<div>${index}-- &gt; ${params.login} </div>`
            })
            // <img src="${params.avatar_url}" width='50px' alt="">
            document.write(nwe)
        }).catch(function (msg) {
            document.write("出错了")
        })
    </script>
   
</body>
</html>
